package com.hunktimes.wholesale.net.model

import android.os.Parcel
import android.os.Parcelable

/**
 * Author: Delete
 * Date: 2020/7/22 17:37
 * Description:
 *
 */

data class ApiResponse<T>(var code: Int, var message: String?, var data: T?) {
    fun isSuccess() = code == 200
}


/*
  {
      "id": 1,
      "name": "banner",
      "info": "描述信息",
      "link": "www.baidu.com",
      "img": "http://e.hiphotos.baidu.com/image/h%3D300/sign=a9e671b9a551f3dedcb2bf64a4eff0ec/4610b912c8fcc3cef70d70409845d688d53f20f7.jpg",
      "sort": 1,
      "status": 1,
      "type": 1,
      "createTime": "2019-11-23 11:39:36",
      "updateTime": "2019-11-23 11:39:40"
    }
 */
data class BannerResp(
//    val id: Long,
//    val name: String,
//    val info: String,
//    val link: String,
    val img: String
//    val sort: Int,
//    val status: Int,
//    val type: Int,
//    val createTime: String,
//    val updateTime: String

)

data class CategoryTag(var isSelect: Boolean = false, val categoryType: String)

/**
 * @param region 地区
 */
data class RecAddress(
    var name: String, var phone: String,
    var region: String, var address: String
)


data class MemberInfo(
    var avatarUrl: String,
    var nickName: String,
    var gender: Int
)

data class MockCategory(val imgUrl: String, val name: String)

data class MockGoods(
    val documentId: String,
    val name: String?, val name2: String,
    val price: String, val imageUrl: String,
    val imageUrl2: String, val productCode: String
) : Parcelable {
    val nameSafe: String
        get() = if (name.isNullOrBlank()) "寶石系列" else name
    val desc: String
        get() =
            """
            分類: ${nameSafe}
            ${name2}
            文件編號: ${documentId}
            產品編號: ${productCode}
            """.trimIndent()

    val priceHK: String
        get() = "HK$ ${price}"

    constructor(parcel: Parcel) : this(
        parcel.readString() ?: "",
        parcel.readString(),
        parcel.readString() ?: "",
        parcel.readString() ?: "",
        parcel.readString() ?: "",
        parcel.readString() ?: "",
        parcel.readString() ?: ""
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(documentId)
        parcel.writeString(name)
        parcel.writeString(name2)
        parcel.writeString(price)
        parcel.writeString(imageUrl)
        parcel.writeString(imageUrl2)
        parcel.writeString(productCode)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<MockGoods> {
        override fun createFromParcel(parcel: Parcel): MockGoods {
            return MockGoods(parcel)
        }

        override fun newArray(size: Int): Array<MockGoods?> {
            return arrayOfNulls(size)
        }
    }
}

data class MockComment(
    val comment: String,
    val username: String,
    val date: String
)